"""
@author: xiangping
@contact: xiangpingbu@gmail.com
@time: 2020/1/10 11:28 下午
@file: shaojie_bellow_status_bo
@Desc:
"""
from app.models.bo.base_bo import BaseBO
from app.utils.constant import ShaoJieStatus


class SJBellowStatusBO(BaseBO):
    time = None
    terminal_status = None

    def __init__(self,
                 model_15m_status,
                 model_5m_status,
                 data_time):
        self.time = data_time
        self.terminal_status = self.get_final_status(model_15m_status, model_5m_status)

    @classmethod
    def get_final_status(self, model_15m_status, model_5m_status):
        flag_15m = model_15m_status in ShaoJieStatus.MODEL_STATUS_NORMAL_DICT.keys()
        flag5m = model_5m_status in ShaoJieStatus.MODEL_STATUS_NORMAL_DICT.keys()
        if (not flag_15m) and flag5m:
            return "波动"
        if (not flag_15m) and (not flag5m):
            return "异常"
        if flag_15m and (not flag5m):
            return "恢复"

        return "正常"
